package engine;

import java.util.HashMap;

public class Logger {
	public static final int NONE = 0;
	public static final int ERROR = 1;
	public static final int WARNING = 2;
	public static final int DEV = 4;
	public static final int ALL = 7;

	private final HashMap<Integer, String> typeNames; 

	private static Logger instance = null;
	private int logLevel;

	public static Logger getInstance() {
		if (instance == null) {
			instance = new Logger();
		}
		
		return instance;
	}

	private Logger() {
		logLevel = NONE;
		
		typeNames = new HashMap<Integer, String>();
		typeNames.put(DEV, "DEV");
		typeNames.put(ERROR, "ERROR");
		typeNames.put(WARNING, "WARNING");
	}

	public void out(int type, String message) {
		if ((logLevel & type) > 0) {
			System.out.println("[" + typeNames.get(type) + "]: " + message);
		}
	}

	public void setLogLevel(int logLevel) {this.logLevel = logLevel;}

}